<template>
  <div>
    <el-row :gutter="10">
      <el-col :span="20">
        <el-form ref="ruleForm" :model="form" :rules="rules" status-icon label-width="100px" class="demo-ruleForm">
          <el-form-item label="密码" prop="password">
            <el-input type="password" v-model="form.password" autocomplete="off">
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
            <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

  </div>
</template>

<script>
export default {
  name: "view_account",
  data() {
    return {
      form: {
        id: "",
        password: ""
      },
      dialogVisible: false,
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      loading: false,
      rules: {
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'}
        ],
      }
    }
  },
  mounted() {
    this.form.id = this.$route.query.id;
  },
  methods: {
    submitForm(done) {
      let self = this;
      this.$refs["ruleForm"].validate(function (valid) {
        if (valid) {
          self.restPassword();
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    async restPassword(done) {
      let params = this.form;
      let res = await this.$http.form("/tenantRest/tenantuser/restPassword.htm", params);
      if (res.code === 0) {
        this.$message({
          message: '重置密码成功',
          type: 'success'
        });
      } else {
        this.$message.error(res.msg);
      }
    }
  },
}
</script>

<style scoped>

</style>
